#!gpxe
<%#
kind: iPXE
name: Preseed default iPXE
model: ProvisioningTemplate
oses:
- Debian
- Ubuntu
test_on:
- debian4dhcp
- ubuntu4dhcp
description: |
  The template to render iPXE installation script for preseed based distributions
  The output is deployed on the host's subnet TFTP proxy.
  See https://ipxe.org/scripting for more details
-%>
<%
  iface = @host.provision_interface
  subnet4 = iface.subnet
  subnet6 = iface.subnet6

  if subnet4 && !subnet4.dhcp_boot_mode?
    url = foreman_url('provision', static: '1')
  elsif subnet6 && !subnet6.dhcp_boot_mode?
    url = foreman_url('provision', static6: '1')
  else
    url = foreman_url('provision')
  end
-%>
echo Trying to ping Gateway: ${netX/gateway}
ping --count 1 ${netX/gateway} || echo Ping to Gateway failed or ping command not available.
echo Trying to ping DNS: ${netX/dns}
ping --count 1 ${netX/dns} || echo Ping to DNS failed or ping command not available.

<% boot_files_uris = @host.operatingsystem.boot_files_uri(medium_provider) -%>
<% kernel = boot_files_uris[0] -%>
<% initrd = boot_files_uris[1] -%>

kernel <%= kernel %> initrd=initrd.img interface=auto url=<%= url %> ramdisk_size=10800 root=/dev/rd/0 rw auto <%= snippet("preseed_kernel_options", variables: {ipxe_net: true}).strip %>

initrd <%= initrd %>

imgstat
sleep 2
boot
